import * as monaco from 'monaco-editor'
import { toRaw } from 'vue'
import { BwMonacoEditorCommandModel } from '../model'

export const createCommands = (
  editor: monaco.editor.IStandaloneCodeEditor,
  commands?: Array<BwMonacoEditorCommandModel>
) => {
  if (editor && commands) {
    commands.forEach((item) => {
      toRaw(editor)?.addCommand(item.keybinding, item.handler, item.context)
    })
  }
}
